package com.yzd.xander.dao.impl;

import com.yzd.xander.dao.HistoryDao;
import com.yzd.xander.entity.History;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by YE on 2018-06-06.
 */
@Repository("historyDao")
@Transactional(readOnly = false)
public class HistoryDaoImpl extends HibernateDaoSupport implements HistoryDao {
    @Override
    public int addHistory(History history) {
        try {
            getHibernateTemplate().save(history);
            return 1;
        } catch (Exception e) {
            return 0;
        }
    }

    @Autowired
    public void setMySessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }
}
